import type { AppRouteModule } from '@/router/types';

import { LAYOUT, getParentLayout } from '@/router/constant';
import { t } from '@/hooks/web/useI18n';

const system: AppRouteModule = {
  path: '/system',
  name: 'System',
  component: LAYOUT,
  redirect: '/system/identity',
  meta: {
    orderNo: 2000,
    icon: 'ion:settings-outline',
    title: t('routes.system.moduleName'),
    roles: [
      // 'Root.Admin.Systems.Logo.UploadLogo',
      // 'Root.Admin.Systems.Logo.DeleteLogo',
      'Root.Admin.Systems.Settings.SetAppTitle',
      'Root.Admin.Systems.Settings.SetAppDescription',
      'Root.Admin.Menu.Route.Read',
      'Root.Admin.Systems.Pack.Read',
      'Root.Admin.Identity.LoginLog.Read',
      'Root.Admin.Identity.User.Read',
      'Root.Admin.Identity.Role.Read',
      'Root.Admin.Identity.Organization.Read',
      'Root.Admin.Auth.Module.Read',
      'Root.Admin.Auth.Function.Read',
      'Root.Admin.Auth.EntityInfo.Read',
      'Root.Admin.Auth.RoleEntity.Read',
      'Root.Admin.Auth.UserEntity.Read',
      'Root.Mobile.Admin.App.ReadSimple',
      'Root.Mobile.Admin.AppVersion.ReadSimple',
    ],
  },
  children: [
    // =============================偏好设置 start=============================
    {
      path: 'preference',
      name: 'PreferencePage',
      component: () => import('@/views/system/preference/index.vue'),
      meta: {
        icon: 'ic:outline-room-preferences',
        title: t('routes.system.preference.title'),
        ignoreKeepAlive: false,
        roles: [
          // 'Root.Admin.Systems.Logo.UploadLogo',
          // 'Root.Admin.Systems.Logo.DeleteLogo',
          'Root.Admin.Systems.Settings.SetAppTitle',
          'Root.Admin.Systems.Settings.SetAppDescription',
        ],
      },
    },
    // =============================偏好设置 end===============================
    // =============================菜单管理 start=============================
    {
      path: 'menu',
      name: 'MenuPage',
      component: () => import('@/views/system/menu/MenuPage.vue'),
      meta: {
        icon: 'ri:menu-add-fill',
        title: t('routes.system.menu.title'),
        ignoreKeepAlive: false,
        roles: ['Root.Admin.Menu.Route.Read'],
      },
    },
    // =============================菜单管理 end===============================
    // =============================系统模块包 start=============================
    {
      path: 'pack',
      name: 'PackPage',
      component: () => import('@/views/system/pack/PackPage.vue'),
      meta: {
        icon: 'uil:package',
        title: t('routes.system.pack.title'),
        ignoreKeepAlive: false,
        roles: ['Root.Admin.Systems.Pack.Read'],
      },
    },
    // =============================系统模块包 end===============================
    // =============================登录日志 start=============================
    {
      path: 'loginlog',
      name: 'LoginLogPage',
      component: () => import('@/views/system/loginlog/LoginLog.vue'),
      meta: {
        icon: 'mdi:login-variant',
        title: t('routes.system.loginlog.title'),
        ignoreKeepAlive: false,
        roles: ['Root.Admin.Identity.LoginLog.Read'],
      },
    },
    // =============================登录日志 end===============================
    // =============================字典管理 start=============================
    {
      path: 'dict',
      name: 'DictManagePage',
      component: () => import('/@/views/system/dicts/DictPage.vue'),
      meta: {
        icon: 'arcticons:colordict',
        title: '字典管理',
        roles: ['Root.Admin.Systems.Dict.ReadDict'],
      },
    },
    // =============================字典管理 end===============================
    // =============================身份认证 start=============================
    {
      path: 'identity',
      name: 'IdentityPage',
      component: getParentLayout('IdentityPage'),
      redirect: '/system/identity/user',
      meta: {
        icon: 'lucide:users',
        title: t('routes.system.identity.title'),
        roles: [
          'Root.Admin.Identity.User.Read',
          'Root.Admin.Identity.Role.Read',
          'Root.Admin.Identity.Organization.Read',
        ],
      },
      children: [
        {
          path: 'user',
          name: 'UserPage',
          component: () => import('@/views/system/identity/user/UserPage.vue'),
          meta: {
            icon: 'la:users-cog',
            title: t('routes.system.identity.user.title'),
            ignoreKeepAlive: false,
            roles: ['Root.Admin.Identity.User.Read'],
          },
        },
        {
          path: 'role',
          name: 'RolePage',
          component: () => import('@/views/system/identity/role/RolePage.vue'),
          meta: {
            icon: 'carbon:user-identification',
            title: t('routes.system.identity.role.title'),
            ignoreKeepAlive: false,
            roles: ['Root.Admin.Identity.Role.Read'],
          },
        },
        {
          path: 'organization',
          name: 'OrganizationPage',
          component: () => import('@/views/system/identity/organization/OrganizationPage.vue'),
          meta: {
            icon: 'clarity:organization-line',
            title: t('routes.system.identity.organization.title'),
            ignoreKeepAlive: false,
            roles: ['Root.Admin.Identity.Organization.Read'],
          },
        },
      ],
    },
    // =============================身份认证 end=============================
    // =============================权限安全 start=============================
    {
      path: 'authorization',
      name: 'AuthorizationPage',
      component: getParentLayout('AuthorizationPage'),
      redirect: '/system/authorization/module',
      meta: {
        icon: 'ic:outline-verified-user',
        title: t('routes.system.authorization.title'),
        roles: [
          'Root.Admin.Auth.Module.Read',
          'Root.Admin.Auth.Function.Read',
          'Root.Admin.Auth.EntityInfo.Read',
          'Root.Admin.Auth.RoleEntity.Read',
          'Root.Admin.Auth.UserEntity.Read',
        ],
      },
      children: [
        {
          path: 'module',
          name: 'ModulePage',
          component: () => import('@/views/system/authorization/module/ModulePage.vue'),
          meta: {
            icon: 'ri:sound-module-fill',
            title: t('routes.system.authorization.module.title'),
            ignoreKeepAlive: false,
            roles: ['Root.Admin.Auth.Module.Read'],
          },
        },
        {
          path: 'function',
          name: 'FunctionPage',
          component: () => import('@/views/system/authorization/function/FunctionPage.vue'),
          meta: {
            icon: 'grommet-icons:action',
            title: t('routes.system.authorization.function.title'),
            ignoreKeepAlive: false,
            roles: ['Root.Admin.Auth.Function.Read'],
          },
        },
        {
          path: 'entityinfo',
          name: 'EntityInfoPage',
          component: () => import('@/views/system/authorization/entityinfo/EntityInfoPage.vue'),
          meta: {
            icon: 'carbon:data-view',
            title: t('routes.system.authorization.entityInfo.title'),
            ignoreKeepAlive: false,
            roles: ['Root.Admin.Auth.EntityInfo.Read'],
          },
        },
        {
          path: 'roleentity',
          name: 'RoleEntityPage',
          component: () => import('@/views/system/authorization/roleentity/RoleEntityPage.vue'),
          meta: {
            icon: 'icon-park-outline:data-display',
            title: t('routes.system.authorization.roleEntity.title'),
            ignoreKeepAlive: false,
            roles: ['Root.Admin.Auth.RoleEntity.Read'],
          },
        },
        {
          path: 'userentity',
          name: 'UserEntityPage',
          component: () => import('@/views/system/authorization/userentity/UserEntityPage.vue'),
          meta: {
            icon: 'icon-park-outline:data-user',
            title: t('routes.system.authorization.userEntity.title'),
            ignoreKeepAlive: false,
            roles: ['Root.Admin.Auth.UserEntity.Read'],
          },
        },
      ],
    },
    // =============================权限安全 end=============================
    // =============================审计管理 start=============================
    {
      path: 'audit',
      name: 'AuditPage',
      component: getParentLayout('AuditPage'),
      redirect: '/system/audit/auditoperation',
      meta: {
        icon: 'codicon:preview',
        title: t('routes.system.audit.title'),
        roles: ['Root.Admin.Audit.AuditOperation.Read', 'Root.Admin.Audit.AuditEntity.Read'],
      },
      children: [
        {
          path: 'auditoperation',
          name: 'AuditOperationPage',
          component: () => import('@/views/system/audit/auditoperation/AuditOperationPage.vue'),
          meta: {
            icon: 'carbon:touch-interaction',
            title: t('routes.system.audit.auditOperation.title'),
            ignoreKeepAlive: false,
            roles: ['Root.Admin.Audit.AuditOperation.Read'],
          },
        },
        {
          path: 'auditentity',
          name: 'AuditEntityPage',
          component: () => import('@/views/system/audit/auditentity/AuditEntityPage.vue'),
          meta: {
            icon: 'fluent:database-link-24-regular',
            title: t('routes.system.audit.auditEntity.title'),
            ignoreKeepAlive: false,
            roles: ['Root.Admin.Audit.AuditEntity.Read'],
          },
        },
      ],
    },
    // =============================审计管理 end=============================
    // =============================文件管理 start=============================
    {
      path: 'files',
      name: 'FilePage',
      component: getParentLayout('FilePage'),
      redirect: '/system/files/file',
      meta: {
        icon: 'mdi:files',
        title: '文件管理',
        roles: [],
      },
      children: [
        {
          path: 'file',
          name: 'FileManagePage',
          component: () => import('@/views/system/files/file/FilePage.vue'),
          meta: {
            icon: 'ph:file-duotone',
            title: '文件列表',
            roles: ['Root.Admin.Systems.File.Read'],
          },
        },
      ],
    },
    // =============================文件管理 end===============================
    // =============================消息管理 start=============================
    {
      path: 'message',
      name: 'Message',
      component: getParentLayout('Message'),
      redirect: '/system/message/message',
      meta: {
        icon: 'icon-park-outline:message-unread',
        title: t('routes.system.message.title'),
        roles: [
          'Root.Admin.Msg.Message.Read',
          'Root.Admin.Msg.QueryMessage.Read',
          'Root.Admin.Msg.TemplateMessage.Read',
        ],
      },
      children: [
        {
          path: 'message',
          name: 'MessagePage',
          component: () => import('@/views/system/message/message/index.vue'),
          meta: {
            icon: 'carbon:email-new',
            title: t('routes.system.message.message.title'),
            ignoreKeepAlive: false,
            roles: ['Root.Admin.Msg.Message.Read'],
          },
        },
        {
          path: 'templatemessage',
          name: 'TemplateMessagePage',
          component: () => import('@/views/system/message/templatemessage/index.vue'),
          meta: {
            icon: 'carbon:message-queue',
            title: t('routes.system.message.templateMessage.title'),
            ignoreKeepAlive: false,
            roles: ['Root.Admin.Msg.TemplateMessage.Read'],
          },
        },
      ],
    },
    // =============================消息管理 end=============================
  ],
};

export default system;
